import _configure from "choerodon-ui/lib/configure";
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";

var _templateObject;

import { createGlobalStyle, StyleSheetManager } from 'styled-components';
import ThemeContext from '@cpaas-front-ui/cfg/lib/utils/ThemeContext';
import { getStyleSheetTarget } from '@cpaas-front-ui/cfg/lib/utils/utils';
import React, { useContext, useEffect } from 'react';
import expandMenuCss from "./expandMenuCss";
import getCommonLayoutStyle from "./LayoutCommon";
import getSideExpandLayoutCss from "./sideExpandLayout";
import getSideCascadeLayoutCss from "./sideCascadeLayout";
import getTopLayoutCss from "./topLayoutCss";
import globalOverride from "./GlobalOverride";
import CpaasGlobalStyle from "./CpaasGlobalStyle";
import C7nPolyfillStyle from "./DefaultC7NPolyfill";
var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n  /* cpaas-layout-global-style */\n  ", "\n  ", "\n  ", "\n  ", "\n  ", "\n  ", "\n"])), getCommonLayoutStyle, getSideExpandLayoutCss, getSideCascadeLayoutCss, getTopLayoutCss, expandMenuCss, globalOverride);
export default (function () {
  var themeCtx = useContext(ThemeContext);
  var theme = {};

  if (themeCtx && themeCtx.originTheme) {
    theme = themeCtx.originTheme;
  }

  var _themeCtx$config = themeCtx.config,
      config = _themeCtx$config === void 0 ? {} : _themeCtx$config;
  var shouldUsePolyfill = !config.current || config.current.schema === 'theme2';
  useEffect(function () {
    if (config.current.schema !== 'theme2') {
      _configure({
        tableRowHeight: 34
      });
    } else {
      _configure({
        tableRowHeight: 36
      });
    }
  }, [config.current.schema]);
  return /*#__PURE__*/React.createElement(StyleSheetManager, {
    target: getStyleSheetTarget('cpaas-ued-theme-layout-and-global-style')
  }, /*#__PURE__*/React.createElement(React.Fragment, null, shouldUsePolyfill && /*#__PURE__*/React.createElement(C7nPolyfillStyle, {
    theme: theme
  }), config.current && config.current.schema !== 'theme2' && /*#__PURE__*/React.createElement(GlobalStyle, {
    theme: theme
  }), /*#__PURE__*/React.createElement(CpaasGlobalStyle, null)));
});